findAll

Purpose

Finds all of the domain class instances for the specified query

Examples

// everything
Book.findAll()
// with a positional parameter
Book.findAll("from Book as b where b.author=?",['Dan Brown'])
// 10 books from Dan Brown staring from 5th book ordered by release date
Book.findAll("from Book as b where b.author=? order by b.releaseDate",['Dan Brown'],[max:10,offset:5])

// examples with max/offset usage def query = "from Book as b where b.author='Dan Brown' order by b.releaseDate" // first 10 books Book.findAll(query,[max:10]) // 10 books starting from 5th Book.findAll(query,[max:10,offset:5])

// examples with named parameters (since 0.5) Book.findAll("from Book as b where b.author=:author", [author:'Dan Brown']) Book.findAll("from Book as b where b.author=:author", [author:'Dan Brown'], [max:10, offset:5]) Book.findAll("from Book as b where b.author in (:authors)", [authors:['Dan Brown','Jack London']])

// examples with tables join Book.findAll("from Book as b where not exists (from Borrow as br where br.book = b)")

// query by example def b = new Book(author:"Dan Brown") Book.findAll(b)

Description

The findAll method allows querying with Hibernate's query language HQL and querying by example for a collection of matching instances. Pagination can be controlled via the max and offset parameters appended to the end:

Book.findAll("from Book as b where b.author=:author", [author:'Dan Brown'], [max:10, offset:5])

The basic syntax for the method is:

Book.findAll()
Book.findAll( String query )
Book.findAll( String query, Collection positionalParams )
Book.findAll( String query, Collection positionalParams, Map paginateParams )
Book.findAll( String query, Map namedParams )
Book.findAll( String query, Map namedParams, Map paginateParams )
Book.findAll( Book example )

Parameters: